<template>
	<view class="pagesBox">
		<view class="pagesMain">
			<view class="recordBox">
				<block v-for="(item,index) in flowRecord" :key="index">
					<view class="recordItem">
						<view class="recordLeft">
							<view class="imageBox">
								<image v-if="!item.money.includes('-')" :src="`${baseUrl}/static/my/icon20.png`" style="width: 80rpx;height: 80rpx;"></image>
								<image v-if="item.money.includes('-')" :src="`${baseUrl}/static/my/icon21.png`" style="width: 80rpx;height: 80rpx;"></image>
							</view>
							<view class="recordInfo">
								<view class="recordTitle">{{item.memo}}</view>
								<view class="recordTime">{{item.time}}</view>
							</view>
						</view>
						<view class="recordRight" :class="[item.money.includes('-') ? 'money1':'money2']">{{item.money}}</view>
					</view>
				</block>
				<uni-load-more v-if="total > 0" :status="statusType"></uni-load-more>
				<view style="margin-top: 20rpx;" v-if="total == 0"><u-empty text="暂无明细" mode="list"></u-empty></view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl:this.$baseUrl,
				flowInfo:{},
				flowRecord:[],
				total:-1,
				statusType:'more',
				params:{
					limit:15,
					page:1
				},
				showExplainTip:false,
			};
		},
		onShow() {
			this.params.page = 1;
			this.getRecord();
		},
		methods:{
			async getRecord(){
				let res = await uni.$http('POST','score/record',this.params);
				if(res.code == 1){
					this.params.page = res.data.current_page;
					this.total = res.data.total;
					if(this.params.page == 1){
						this.flowRecord = res.data.data;
					}else{
						this.flowRecord = this.flowRecord.concat(res.data.data);
					}
					if(this.flowRecord.length < this.total){
						this.statusType = 'more'
					}else{
						this.statusType = 'noMore'
					}
				}else if(res.msg.includes('登录')){
					this.total = 0;
					uni.removeStorageSync("token")
				}else{
					this.total = 0;
				}
			},
			fmtMoney(money = 0){
				let num = Number(money).toLocaleString('zh-CN', {style: 'currency',currency: 'CNY'})
				return num.replace('¥','')
			},
			// 前往我的确权号
			toDuihuanNo(){
				uni.navigateTo({
					url:"/pagesMy/duihuanNo/duihuanNo"
				})
			}
		},
		onReachBottom() {
			if(this.flowRecord.length < this.total){
				this.statusType = 'loading';
				this.params.page++;
				this.getRecord()
			}else{
				this.statusType = 'noMore'
			}
		}
	}
</script>

<style scoped lang="scss">
.pagesBox{
	.bgColor{
		height: 300rpx;
		background: linear-gradient(#ef4a3f 0% , #F7F8FA 100%);
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
	}
	.pagesMain{
		padding: 12rpx 24rpx;
		position: relative;
		.trafficBox{
			font-size: 0%;
			display: flex;
			justify-content: center;
			align-items: center;
			position: relative;
			.trafficMain{
				padding: 8rpx 24rpx;
				position: absolute;
				top: 0%;
				right: 0%;
				bottom: 0%;
				left: 0%;
				.trafficTop{
					height: calc(100% - 88rpx);
					display: flex;
					justify-content: space-between;
					align-items: center;
					.trafficItemBox{
						width: 49.5%;
						padding-left: 24rpx;
						.trafficItemTitle{
							font-weight: 400;
							font-size: 24rpx;
							color: #A1A5AA;
						}
						.trafficItemNum{
							font-weight: 600;
							font-size: 34rpx;
							color: #FF6938;
						}
					}
					.borderLeft{
						border-left: #324E6A 2rpx solid;
					}
				}
				.trafficBottom{
					height: 88rpx;
					.cellBox{
						height: 100%;
						padding: 0rpx 10rpx 0rpx 26rpx;
						display: flex;
						justify-content: space-between;
						align-items: center;
						.cellLeft{
							display: flex;
							align-items: center;
							.cellIcon{
								margin-right: 8rpx;
								display: flex;
								justify-content: center;
								align-items: center;
							}
							.cellTitle{
								font-weight: 600;
								font-size: 28rpx;
								color: #FFFFFF;
							}
						}
						.cellRight{
							font-weight: 400;
							font-size: 26rpx;
							color: #A1A5AA;
						}
					}
				}
			}
		}
		.recordBox{
			background-color: #FFFFFF;
			border-radius: 16rpx;
			padding: 0 24rpx;
			.recordItem{
				border-bottom: 2rpx solid #f7f8fa;
				display: flex;
				justify-content: space-between;
				align-items: center;
				&:last-of-type{
					border-bottom: 0rpx;
				}
				.recordLeft{
					font-weight: 400;
					font-size: 32rpx;
					color: #16202B;
					padding: 24rpx 0;
					margin-bottom: 8rpx;
					display: flex;
					justify-content: center;
					align-items: center;
					.imageBox{
						font-size: 0%;
						margin-right: 12rpx;
					}
					.recordInfo{
						.recordTitle{
						    font-weight: 600;
						    font-size: 30rpx;
						    color: #000;
						}
						.recordTime{
						    font-weight: 400;
						    font-size: 24rpx;
						    color: #A1A5AA;
							margin-top: 6rpx;
						}
					}
				}
				.money1{
					font-weight: 600;
					font-size: 30rpx;
					color: #FF6938;
				}
				.money2{
					font-weight: 600;
					font-size: 30rpx;
					color: #53C588;
				}
			}
		}
	}
}
</style>
<style>
	page{
		background-color: #f7f8fa;
	}
</style>